package com.kaishengit.web;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.kaishengit.entity.BookType;
import com.kaishengit.util.web.ServletUtil;

import service.BookTypeService;

public class BookTypeEdit extends HttpServlet {
	private static final long serialVersionUID = 1L;
	BookTypeService service=new BookTypeService();
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String id=request.getParameter("id");
		BookType bookType=service.findById(id);
		ServletUtil.setRequestAttribute(request,"bookType", bookType);
		ServletUtil.forward(request, response, "/admin/bookTypeEdit");
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String id=request.getParameter("id");
		String typeName=request.getParameter("typeName");
		service.updateBookType(id,typeName);
		
		ServletUtil.redirect(response, "bookTypeManager.jspx");
	}

}
